package com.foodplus.www.model.impl;

import com.foodplus.www.api.RetrofitManager;
import com.foodplus.www.bean.basket.AddGoodBean;
import com.foodplus.www.bean.basket.BasketBean;
import com.foodplus.www.bean.basket.BasketGoodNumBean;
import com.foodplus.www.model.IBasketModel;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by WangZhiChao on 2016/11/2.
 */

public class BasketModelImpl implements IBasketModel {
    @Override
    public void getBasketData(Map<String, String> params, Subscriber<BasketBean> subscriber) {
        RetrofitManager
                .getInstance()
                .getBasketService()
                .getBasketList(params)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }

    @Override
    public void getBasketGoodNumData(Map<String, String> params, Subscriber<BasketGoodNumBean> subscriber) {
        RetrofitManager
                .getInstance()
                .getBasketService()
                .getBasketGoodNumList(params)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }


    @Override
    public void addToBasket(Map<String, String> params, Subscriber<AddGoodBean> subscriber) {
        RetrofitManager.getInstance().getBasketService().addToBasketList(params).observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }
}
